package com.example.database.slice;

import com.example.database.*;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener {

    private Button mBtnRdb;
    private Button mBtnOrm;
    private Button mBtnPreference;
    private Button mBtnDistributed;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        mBtnRdb = (Button) findComponentById(ResourceTable.Id_btn_rdb);
        mBtnRdb.setClickedListener(this);
        mBtnOrm = (Button) findComponentById(ResourceTable.Id_btn_orm);
        mBtnOrm.setClickedListener(this);
        mBtnPreference = (Button) findComponentById(ResourceTable.Id_btn_preference);
        mBtnPreference.setClickedListener(this);
        mBtnDistributed = (Button) findComponentById(ResourceTable.Id_btn_distributed);
        mBtnDistributed.setClickedListener(this);
    }

    @Override
    public void onClick(Component component) {

        if (component.getId() == ResourceTable.Id_btn_rdb) {
            // 启动RdbAbility
            startAbility(Utils.generatePageNavigationIntent(RdbAbility.class.getName()));
        }
        if (component.getId() == ResourceTable.Id_btn_orm) {
            // 启动OrmAbility
            startAbility(Utils.generatePageNavigationIntent(OrmAbility.class.getName()));
        }
        if (component.getId() == ResourceTable.Id_btn_preference) {
            // 启动PreferenceAbility
            startAbility(Utils.generatePageNavigationIntent(PreferenceAbility.class.getName()));
        }
        if (component.getId() == ResourceTable.Id_btn_distributed) {
            // 启动DistributedAbility
            startAbility(Utils.generatePageNavigationIntent(DistributedAbility.class.getName()));
        }
    }
}
